package net.csdn.business.kanban.common.domain.DTO;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.csdn.business.kanban.common.constant.CommonConstants;

import java.util.Objects;

/**
 * @author wanghang
 * @version 1.0
 * @date 2022/11/7 16:24
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MilepostIssueSumVo {

    /**
     * issue总数
     */
    private Integer issueTotal;

    /**
     * 开启中的issue总数
     */
    private Integer issueOn;

    /**
     * 已关闭的issue总数
     */
    private Integer issueClose;

    /**
     * 完成度百分比（保留两位小数）
     */
    private Double rate;

    public static MilepostIssueSumVo buildEmpty() {
        return MilepostIssueSumVo.builder()
                .issueOn(CommonConstants.INT_ZERO)
                .issueClose(CommonConstants.INT_ZERO)
                .issueTotal(CommonConstants.INT_ZERO)
                .rate(CommonConstants.DOUBLE_ZERO)
                .build();
    }

    public static MilepostIssueSumVo formatStat(MilepostIssueSumVo sumVo) {
        if (Objects.isNull(sumVo)) {
            return MilepostIssueSumVo.buildEmpty();
        }
        return sumVo;
    }

    @Data
    public static class GoalStat {
        private String goalId;
        private Integer status;
        private Integer total;
    }

}
